Skip to content

Comments

Fix propagation of global attributes to child datasets and variables#72

Open
clarasb wants to merge 6 commits intomainfrom
clarasb-63-datatree_global_attrs
Open

Fix propagation of global attributes to child datasets and variables#72
clarasb wants to merge 6 commits intomainfrom
clarasb-63-datatree_global_attrs

Conversation

@clarasb
Copy link
Collaborator

@clarasb clarasb commented Jan 8, 2026

This PR fixes passing of global datatree attributes to children. Attributes defined on parent datatrees are now inherited by all descendants.

Closes #63.

Checklist (strike out non-applicable):

  • Changes documented in CHANGES.md
  • Related issue exists and is referred to in the PR description and CHANGES.md
  • Added docstrings and API docs for any new/modified user-facing classes and functions
  • Changes/features documented in docs/*
  • Unit-tests adapted/added for changes/features
  • Test coverage remains or increases (target 100%)

@codecov
Copy link

codecov bot commented Jan 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.48%. Comparing base (353e655) to head (e27d640).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #72   +/-   ##
=======================================
  Coverage   99.48%   99.48%           
=======================================
  Files          74       74           
  Lines        2927     2932    +5     
  Branches      425      425           
=======================================
+ Hits         2912     2917    +5     
  Partials       15       15           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@clarasb clarasb marked this pull request as ready for review January 12, 2026 11:47
Copy link
Member

@forman forman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix:

  • It is not clear, why the fix is correct. New code is also quite unintuitive.
  • Missing unit tests

@clarasb clarasb requested a review from forman January 27, 2026 09:17
rule_op.validate_datatree(context, node)

if node.datatree.is_leaf:
# Inherit attrs from the parent datatree into the child dataset
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just explains what the code does, but this is obvious. Please answer the question why this is done. What issues is solved by copying attributes.

)
else:
for name, datatree in node.datatree.children.items():
# Inherit attrs from the parent datatree into the child datatree
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Comment on lines +25 to +26
- Fixed passing of global datatree attributes to children: attributes defined
on parent datatrees are now inherited by all descendants. (#63)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? To me this sounds like an xarray bug for which we provide a workaround here. Why do we have to inherit them manually? To me it seems we are copying attributes from a parent group into a child group - that would be wrong as it does not reflect the true physical structure of the Zarr dataset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Attributes from parent group not recognized

2 participants